import 'package:flutter/material.dart';
import 'dart:ui';

class HexColor extends Color {
  static int _getColorFromHex(String hexColor) {
    hexColor = hexColor.toUpperCase().replaceAll("#", "");
    if (hexColor.length == 6) {
      hexColor = "FF" + hexColor;
    }
    return int.parse(hexColor, radix: 16);
  }

  HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
}

class Design{

  
  static final double ScreenWidth = window.physicalSize.width > window.physicalSize.height ? window.physicalSize.width : window.physicalSize.height;
  static final double DesignWidth = 1920;

  static double px(int size){
    if(size == 0){
      return 0;
    }
    if(DesignWidth == ScreenWidth){
      return size * 1.0;
    }

    double r = size / DesignWidth * ScreenWidth / window.devicePixelRatio;
    print('Design.px($size)  ====>  $r     [screenWidth=$ScreenWidth， devicePixelRatio=${window.devicePixelRatio}]');
    return r;
  }
}